
var vm=new Vue({
  el:"#app",
  data:{
    isLoading:true,
    pageSize:PAGESIZE,
    pageIndex:1,
    goldList:[],
    reqOut: false //判断请求数据是否已完
  },
  compiled: function(){
    var _self = this;
    $('.recordList ul').css('min-height',$(window).height()-$('.header').outerHeight());
    $(document).scroll(function () {
      if ($(document).scrollTop() >= $(document).height() - $(window).height()) {
        if (!_self.reqOut) {
          var str = '<img class="loading-img" src="images/loading.gif"></img>';
          myLoad.pullLoad('recordList', str);
          _self.loadlist(_self.tabs);
        }
      }
    });

    _self.loadlist(_self.tabs);
  },
  methods:{
    loadlist:function(tabs){
      var _self = this;
      var vModal,target;  //用来储存不同的tab页面对应的对象
      var url = 'user_getGoldHistoryList';
      var data = {
        pageSize:_self.pageSize,
        pageIndex:_self.pageIndex
      }; 

      vModal = _self;
      target = _self.goldList;

      if(!vModal.isLoading) return;
      data = Common.jsonEncode(data);
      Common.ajaxCall({ url: url, datatype: 'json', type: 'post', data: data}, function (data) {
          if(data.error_code==0 && data.data.length > 0){
              if(vModal.pageIndex==1){
                target.length = 0;
              }
              for(var i = 0; i < data.data.length; i++){
                target.push(data.data[i]);
              }
              _self.reqOut = false;

              //实际数据与请求的数据量比较
              if (data.data.length >= vModal.pageSize) {
                  myLoad.pullHide(); //加载后，把效果去掉
              } else {
                  _self.reqOut = true;
                  myLoad.noDate(); //暂无数据
                  vModal.isLoading = false;
              }
          }else{
              _self.reqOut = true;
              myLoad.noDate(); //暂无数据
              vModal.isLoading = false;
          }

          vModal.pageIndex++;
      });
      
    }
  }
});